.PHONY: clean doc modclean mod goinstall build dist deb

TARGET_OS = windows darwin linux freebsd
TARGET_ARCH = amd64 arm 386 arm64

TARGET_ENGINE = update
TARGET_DIR = ./dist
GO_BUILD = go build

FLAGS = -ldflags="-H windowsgui"

default: build

build:
	rm -rf ./dist
	$(MAKE) buildwin
	$(MAKE) buildmac
	$(MAKE) buildlinux
buildwin:
	GOOS=windows GOARCH=amd64 CGO_ENABLED=0 $(GO_BUILD) $(FLAGS) -o $(TARGET_DIR)/$(TARGET_ENGINE)_windows_amd64.exe;
	GOOS=windows GOARCH=arm CGO_ENABLED=0 $(GO_BUILD) $(FLAGS) -o $(TARGET_DIR)/$(TARGET_ENGINE)_windows_arm.exe;
	GOOS=windows GOARCH=386 CGO_ENABLED=0 $(GO_BUILD) $(FLAGS) -o $(TARGET_DIR)/$(TARGET_ENGINE)_windows_386.exe;
	GOOS=windows GOARCH=arm64 CGO_ENABLED=0 $(GO_BUILD) $(FLAGS) -o $(TARGET_DIR)/$(TARGET_ENGINE)_windows_arm64.exe;
buildmac:
	GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 $(GO_BUILD) -o $(TARGET_DIR)/$(TARGET_ENGINE)_darwin_amd64;
	GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 $(GO_BUILD) -o $(TARGET_DIR)/$(TARGET_ENGINE)_darwin_arm64;
buildlinux:
	GOOS=linux GOARCH=amd64 CGO_ENABLED=0 $(GO_BUILD) -o $(TARGET_DIR)/$(TARGET_ENGINE)_linux_amd64;
	GOOS=linux GOARCH=arm CGO_ENABLED=0 $(GO_BUILD) -o $(TARGET_DIR)/$(TARGET_ENGINE)_linux_arm;
	GOOS=linux GOARCH=386 CGO_ENABLED=0 $(GO_BUILD) -o $(TARGET_DIR)/$(TARGET_ENGINE)_linux_386;
	GOOS=linux GOARCH=arm64 CGO_ENABLED=0 $(GO_BUILD) -o $(TARGET_DIR)/$(TARGET_ENGINE)_linux_arm64;
